﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
using System.Runtime.Remoting.Channels;

namespace Winform_test_004
{
    class DbHelper
    {
        private static string conSting = "server =.;database=Schools;uid=sa;pwd=123456";
        public static DataTable GetDataTable(string sql)
        {
            SqlConnection connection = new SqlConnection(conSting);

            SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);

            DataTable dt = new DataTable();

            connection.Open();

            adapter.Fill(dt);

            return dt;

        }

        public static int AddOrUpdateDelete(string sql) 
        {
            SqlConnection connection = new SqlConnection(conSting);

            SqlCommand command = new SqlCommand(sql, connection);

            connection.Open();

            return command.ExecuteNonQuery();
        }

            


            

            


             




    }
}
